package com.yinxin.wudasuanfa.huaweiod;

import java.util.*;

/**
 * @author yinxin
 * @version 1.0
 * @Description:明明生成了NN个1到500之间的随机整数。请你删去其中重复的数字，即相同的数字只保留一个，
 * 把其余相同的数去掉，然后再把这些数从小到大排序，按照排好的顺序输出。
 * 数据范围： 1 \le n \le 1000 \1≤n≤1000  ，输入的数字大小满足 1 \le val \le 500 \1≤val≤500
 * @date 2022/5/1219:27
 */
public class Exercise10 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>(n);
        while (n>0){
            n--;
            int anInt = sc.nextInt();
            if(anInt>=1&&anInt<=500){
                list.add(anInt);
            }else {
                n++;
            }
        }
        HashSet<Integer> set = new HashSet<>(list);
        ArrayList<Integer> arrayList = new ArrayList<>(set);
        mysort(arrayList);
        for (int i = 0; i < arrayList.size(); i++) {
            System.out.println(arrayList.get(i));
        }
    }

    private static void mysort(ArrayList<Integer> arrayList) {
        for (int i = arrayList.size()/2-1; i >=0; i--) {
            heapify(arrayList, arrayList.size(), i);
        }
        for (int i = arrayList.size() - 1; i > 0; i--) {
            int tmp=arrayList.get(i);
            arrayList.set(i,arrayList.get(0));
            arrayList.set(0,tmp);
            heapify(arrayList,i,0);
        }
    }

    private static void heapify(ArrayList<Integer> arrayList, int size, int i) {
        int largest = i;
        int lson = 2*i+1;
        int rson = 2*i+2;
        if(lson<size&&arrayList.get(largest)<arrayList.get(lson)){
            largest=lson;
        }
        if(rson<size&&arrayList.get(largest)<arrayList.get(rson)){
            largest=rson;
        }
        if(largest!=i){
            int tmp=arrayList.get(i);
            arrayList.set(i,arrayList.get(largest));
            arrayList.set(largest,tmp);
            heapify(arrayList,size,largest);
        }
    }

}
